/**
 * @format
 */

import { AppRegistry, Platform, UIManager, useColorScheme } from 'react-native'
import App from './src/App'
import { name as appName } from './app.json'
import { PaperProvider, MD3LightTheme as DefaultTheme } from 'react-native-paper'
import darkTheme from '@/theme/darkTheme.json'
import lightTheme from '@/theme/lightTheme.json'

// 开启安卓动画布局动画
if (Platform.OS === 'android') {
  if (UIManager.setLayoutAnimationEnabledExperimental) {
    UIManager.setLayoutAnimationEnabledExperimental(true)
  }
}

export default function Main() {
  const themeColor = useColorScheme()
  // 创建主题
  const theme = {
    ...DefaultTheme,
    colors: themeColor === 'light' ? lightTheme.colors : darkTheme.colors
  }
  return (
    <PaperProvider theme={theme}>
      <App />
    </PaperProvider>
  )
}

AppRegistry.registerComponent(appName, () => Main)
